//package com.gxd.rocketmq.config;
//
//import com.alibaba.rocketmq.client.exception.MQClientException;
//import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
//import com.gxd.rocketmq.exception.RocketMQException;
//import org.apache.commons.lang3.StringUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.SpringBootConfiguration;
//import org.springframework.context.annotation.Bean;
///**
// * @Author:gxd
// * @Description:
// * @Date: 15:38 2018/1/10
// * @Modified By:
// */
//@SpringBootConfiguration
//public class RocketMQProducerConfiguration {
//    public static final Logger LOGGER = LoggerFactory.getLogger(RocketMQProducerConfiguration.class);
//    @Value("${rocketmq.producer.groupName}")
//    private String groupName;
//    @Value("${rocketmq.producer.namesrvAddr}")
//    private String namesrvAddr;
//    @Value("${rocketmq.producer.instanceName}")
//    private String instanceName;
//    @Value("${rocketmq.producer.maxMessageSize}")
//    private int maxMessageSize ; //4M
//    @Value("${rocketmq.producer.sendMsgTimeout}")
//    private int sendMsgTimeout ;
//
//    @Bean
//    public DefaultMQProducer getRocketMQProducer() throws RocketMQException {
//        if (StringUtils.isBlank(this.groupName)) {
//            throw new RocketMQException("groupName is blank");
//        }
//        if (StringUtils.isBlank(this.namesrvAddr)) {
//            throw new RocketMQException("nameServerAddr is blank");
//        }
//        if (StringUtils.isBlank(this.instanceName)){
//            throw new RocketMQException("instanceName is blank");
//        }
//        DefaultMQProducer producer;
//        producer = new DefaultMQProducer(this.groupName);
//        producer.setNamesrvAddr(this.namesrvAddr);
//        producer.setInstanceName(instanceName);
//        producer.setMaxMessageSize(this.maxMessageSize);
//        producer.setSendMsgTimeout(this.sendMsgTimeout);
//        try {
//            producer.start();
//            LOGGER.info(String.format("producer is start ! groupName:[%s],namesrvAddr:[%s]"
//                    , this.groupName, this.namesrvAddr));
//        } catch (MQClientException e) {
//            LOGGER.error(String.format("producer is error {}"
//                    , e.getMessage(),e));
//            throw new RocketMQException(e);
//        }
//        return producer;
//    }
//}
